import { SystemSetter } from "../../system/SystemSetter";
import { ClassTypesUtil } from "../ClassTypesUtil";
import { Cache } from "../../../cache/Cache";
import { Dispatcher } from "../../../../mvc/core/Dispatcher";
import { DataEvent } from "../../../events/DataEvent";
import { EventName } from "../../../mvc/EventName";
type int = number;
//class AutoGuideStepRecorder
    
    export  class AutoGuideStepRecorder
    {
        constructor()
        {
            
            this._doneSteps = new Map<any, any> /* flash.utils.Dictionary */();
            this._doingSteps = new Map<any, any> /* flash.utils.Dictionary */();
            this._curDoneSteps = new Map<any, any> /* flash.utils.Dictionary */();
            return;
        }

        public init(): void
        {
            var loc3=0;
            var loc4=0;
            var loc1=SystemSetter.localSetter.autoGuides;
            if (loc1 == null || loc1.length == 0) 
            {
                return;
            }
            var loc2=0;
            while (loc2 < loc1.length) 
            {
                loc3 = loc1[loc2];
                loc4 = ClassTypesUtil.getHighestBitPlace(loc3);
                this._doneSteps[loc2] = loc4;
                if (loc2 == 2 && (loc4 == 3 || loc4 == 4) && Cache.instance.task.getDoingTaskByCode(2001022) == null) 
                {
                    this._doneSteps[loc2] = 5;
                    this.saveStepDone(2, 5);
                }
                ++loc2;
            }
            return;
        }

        public saveStepDone(arg1: int, arg2: int): void
        {
            if (SystemSetter.localSetter.autoGuides == null) 
            {
                SystemSetter.localSetter.autoGuides = [];
            }
            if (SystemSetter.localSetter.autoGuides[arg1] == null) 
            {
                SystemSetter.localSetter.autoGuides[arg1] = 0;
            }
            var loc1=SystemSetter.localSetter.autoGuides[arg1];
            loc1 = ClassTypesUtil.getSetBitValueResult(loc1, (arg2 - 1), 1);
            SystemSetter.localSetter.autoGuides[arg1] = loc1;
            this.saveRecord();
            return;
        }

        public getIsStepFinished(arg1: int, arg2: int): Boolean
        {
            var loc1=SystemSetter.localSetter.autoGuides;
            if (loc1 == null || loc1.length == 0) 
            {
                return false;
            }
            var loc2=int(loc1[arg1]);
            return ClassTypesUtil.getBitValue(loc2, arg2) > 0;
        }

        public getHighestGuideStep(arg1: int): int
        {
            var loc1=0;
            if (SystemSetter.localSetter.autoGuides == null) 
            {
                SystemSetter.localSetter.autoGuides = [];
            }
            var loc2=int(SystemSetter.localSetter.autoGuides[arg1]);
            var loc3=0;
            while (loc3 < 31) 
            {
                if (ClassTypesUtil.getBitValue(loc2, loc3) == 1) 
                {
                    loc1 = loc3;
                }
                ++loc3;
            }
            return loc1;
        }

        public getDoneStep(arg1: int): int
        {
            return int(this._doneSteps[arg1]);
        }

        public addDoneStep(arg1: int, arg2: int): void
        {
            this._doneSteps[arg1] = arg2;
            return;
        }

        public get doingStes(): Map<any, any> /* flash.utils.Dictionary */
        {
            return this._doingSteps;
        }

        public addDoingStep(arg1: int, arg2: int): void
        {
            this._doingSteps[arg1] = arg2;
            return;
        }

        public delDoingId(arg1: int): void
        {
            this._doingSteps[arg1] = 0;
            return;
        }

        public getDoingStep(arg1: int): int
        {
            return int(this._doingSteps[arg1]);
        }

        public addCurDonStep(arg1: int, arg2: int): void
        {
            this._curDoneSteps[arg1] = arg2;
            return;
        }

        public getCurDoneStep(arg1: int): int
        {
            return int(this._curDoneSteps[arg1]);
        }

        /* internal  */saveRecord(): void
        {
            Dispatcher.dispatchEvent(new DataEvent(EventName.Sys_SaveInfoNotShowInWindow));
            return;
        }

        /* internal */ /* var */_doneSteps: Map<any, any> /* flash.utils.Dictionary */;

        /* internal */ /* var */_doingSteps: Map<any, any> /* flash.utils.Dictionary */;

        /* internal */ /* var */_curDoneSteps: Map<any, any> /* flash.utils.Dictionary */;
    }
